package com.lin.exception;

import org.springframework.ui.Model;
import org.springframework.validation.BindException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;


@ControllerAdvice
public class GlobalException {
        @ExceptionHandler(value = BindException.class)
        public String bindException(BindException ex, Model model){
                model.addAttribute("error",ex.getAllErrors().get(0).getDefaultMessage());
                return "login";
        }
}
